package com.css.crm.vo;

import java.util.Date;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.css.crm.utility.DateUtil;

@XmlRootElement(name = "customer-service-event")
public class CustomerServiceEventVo extends AuditTrailVo {

	public CustomerServiceEventVo() {
		super();
	}

	/** CUST_SERV_EVENT_ID **/
	private Long custServEventId;
	/** CUST_ID **/
	private String custId;
	/** EVENT_CDE **/
	private String eventCde;
	/** EVENT_DESC **/
	private String eventDesc;
	/** EVENT_DTE **/
	private Date eventDte;
	/** REMARK1 **/
	private String remark1;
	/** REMARK2 **/
	private String remark2;
	@XmlElement
	public Long getCustServEventId() {
		return custServEventId;
	}

	public void setCustServEventId(Long custServEventId) {
		this.custServEventId = custServEventId;
	}
	@XmlElement
	public String getCustId() {
		return custId;
	}

	public void setCustId(String custId) {
		this.custId = custId;
	}
	@XmlElement
	public String getEventCde() {
		return eventCde;
	}

	public void setEventCde(String eventCde) {
		this.eventCde = eventCde;
	}
	@XmlElement
	public String getEventDesc() {
		return eventDesc;
	}

	public void setEventDesc(String eventDesc) {
		this.eventDesc = eventDesc;
	}
	@XmlElement
	public Date getEventDte() {
		return eventDte;
	}

	public void setEventDte(Date eventDte) {
		this.eventDte = eventDte;
	}
	@XmlElement
	public String getRemark1() {
		return remark1;
	}

	public void setRemark1(String remark1) {
		this.remark1 = remark1;
	}
	@XmlElement
	public String getRemark2() {
		return remark2;
	}

	public void setRemark2(String remark2) {
		this.remark2 = remark2;
	}

	@Override
	public int compareTo(AuditTrailVo o) {
		CustomerServiceEventVo vo = (CustomerServiceEventVo) o;
		if (vo == null) {
			// if not set original data, default set to modified.
			return 1;
		}
		String custId = this.getCustId() == null ? "" : this.getCustId();
		String eventCode = this.getEventCde() == null ? "" : this.getEventCde();
		String eventDesc = this.getEventDesc() == null ? "" : this.getEventDesc();
		String eventDate = DateUtil.formatDate(this.getEventDte());
		eventDate = eventDate == null ? "" : eventDate;
		String remark1 = this.getRemark1() == null ? "" : this.getRemark1();
		String remark2 = this.getRemark2() == null ? "" : this.getRemark2();

		String custIdCompareTo = vo.getCustId() == null ? "" : vo.getCustId();
		String eventCodeCompareTo = vo.getEventCde() == null ? "" : vo.getEventCde();
		String eventDescCompareTo = vo.getEventDesc() == null ? "" : vo.getEventDesc();
		String eventDateCompareTo = DateUtil.formatDate(vo.getEventDte());
		eventDateCompareTo = eventDateCompareTo == null ? "" : eventDateCompareTo;
		String remark1CompareTo = vo.getRemark1() == null ? "" : vo.getRemark1();
		String remark2CompareTo = vo.getRemark2() == null ? "" : vo.getRemark2();

		// check if have any field be modified
		int result = 0;
		if (!custId.equals(custIdCompareTo)) {
			result = 1;
		}
		if (!eventCode.equals(eventCodeCompareTo)) {
			result = 1;
		}
		if (!eventDesc.equals(eventDescCompareTo)) {
			result = 1;
		}
		if (!eventDate.equals(eventDateCompareTo)) {
			result = 1;
		}
		if (!remark1.equals(remark1CompareTo)) {
			result = 1;
		}
		if (!remark2.equals(remark2CompareTo)) {
			result = 1;
		}
		return result;
	}

}
